<script type="text/javascript">
	var pfepJs = {
		_wareChange: function(s) {
			var $this = $('>:selected', $(s));
			if ($this.attr('flag') == 0) {
				$('#storageLocation', $.pdialog.getCurrent()).removeClass('required');
			} else {
				$('#storageLocation', $.pdialog.getCurrent()).addClass('required');
			}
		},
		_checknum: function(obj) {
			if (/^\d+\.?\d{0,2}$/.test(obj.value)) {
				obj.value = obj.value;
			} else {
				obj.value = obj.value.substring(0, obj.value.length - 1);
			}
		},
		_tsubmit: function(t) {
			var $form = $(t);
			if (!$form.valid()) {
				return false;
			}
			var id=$('#id', $.pdialog.getCurrent()).val();
			if(!id){
				var code = $('#materialLookup\\.materialCode', $.pdialog.getCurrent()).val();
				var result;
				$.ajax({
					type: 'POST',
					url: '${rc.getContextPath()}/manage/pfep/isExistsPfep',
					data: {
						materialCode: code
					},
					dataType: "text",
					async:false,
					success: function(data) {
						result = data;	
					},
					error: DWZ.ajaxError
				});
				if (result=="false") {
					return false;
				}
			}
			
			return validateCallback(t, dialogAjaxDone);
		}
	};
</script>
<div class="pageContent">
	<form method="post" action="${rc.getContextPath()}/manage/pfep/savePfep" class="pageForm required-validate" onsubmit="return pfepJs._tsubmit(this);">
		<input type="hidden" name="navTabId" value="${navTabId!''}" /> <input id="id" type="hidden" name="id" value="<#if (pfep.materialCode)??>${pfep.materialCode!''}</#if>">
		<div class="pageFormContent">
			<fieldset>
				<dl>
					<dt><@label key='materialCode.C,colon'>物料编号：</@label></dt>
					<dd class="lookInput">
					   <#if pfep.materialCode?? >
					   <input class="required" type="text" name="materialCode" value="${pfep.materialCode!''}" readonly>
					   <#else>
						<input class="look required" type="text" name="materialCode" value="${pfep.materialCode!''}" id="materialLookup.materialCode" type="text" postField="materialCode" suggestFields="materialCode,materialText" suggestUrl="${rc.getContextPath()}/manage/material/componentSuggest" lookupGroup="materialLookup" warn="<@label key='materialCode.C,remote.M'>物料编号已经存在</@label>" remote="${rc.getContextPath()}/manage/pfep/isExistsPfep" /> <a class="btnLook" href="${rc.getContextPath()}/manage/material/componentLookUp?lookupType=radio" rel="materialLookup_dialog" title="<@label key='select.C,materialCode.C'>选择物料</@label>" lookupGroup="materialLookup"></a>
					   </#if>
					</dd>
				</dl>
				<dl>
					<dt><@label key="pullStrategy.C,colon">拉动策略：</@label></dt>
					<dd>
						<select name="pullStrategyCode" class="required"> <#list pullStrategys as pullStrategy>
							<option value="${pullStrategy.pullStrategyCode}"<#if pfep.pullStrategyCode?? && pfep.pullStrategyCode == pullStrategy.pullStrategyCode> selected="selected"</#if>>${pullStrategy.pullStrategyCode}-${pullStrategy.pullStrategyText}</option> </#list>
						</select>
					</dd>
				</dl>
				<dl>
					<dt><@label key="distributionMode.C,colon">配送形式：</@label></dt>
					<dd>
						<select name="distributionModeCode" class="required"> <#list distributionModes as distributionMode>
							<option value="${distributionMode.distributionModeCode}"<#if pfep.distributionModeCode?? && pfep.distributionModeCode == distributionMode.distributionModeCode> selected="selected"</#if>>${distributionMode.distributionModeCode}-${distributionMode.distributionModeText}</option> </#list>
						</select>
					</dd>
				</dl>
				<dl>
					<dt><@label key="defaultWarehouse.C,colon">默认线边仓库：</@label></dt>
					<dd>
						<select onchange="pfepJs._wareChange(this)" id="warehouse" class="allyselect required" ref="storageLocation" postField="warehousCode" refUrl="${rc.getContextPath()}/manage/pfep/warehouseChange" name="warehouseCode" class="required"> <#list warehouses as warehouse>
							<option flag="${warehouse.locationManageFlag}" value='${warehouse.warehouseCode}'<#if pfep.warehouseCode?? && pfep.warehouseCode == warehouse.warehouseCode> selected="selected"</#if>> ${warehouse.warehouseCode}-${warehouse.warehouseText}</option> </#list>
						</select>
					</dd>
				</dl>
				<dl>
					<dt><@label key="defaultStorageLocation.C,colon">默认线边库位：</@label></dt>
					<dd>
						<select selectedValue="${pfep.storageLocationCode!''}" id="storageLocation" field="storageLocationCode" name="storageLocationCode" label="storageLocationText" class="required">
						</select>
					</dd>
				</dl>
				<dl>
					<dt><@label key="distributionCycle.C,colon">默认配送周期：</@label></dt>
					<dd>
						<input name="distributionCycle" class="digits required" maxlength="7" min="1" value="<#if (pfep.distributionCycle)??>${pfep.distributionCycle!''}</#if>" type="text" maxlength="60" />
					</dd>
				</dl>
				<dl>
					<dt><@label key="distributionQuantity.C,colon">默认单次配送量：</@label></dt>
					<dd>
						<input name="distributionQuantity" class="digits required"  maxlength="7" min="1" value="<#if (pfep.distributionQuantity)??>${pfep.distributionQuantity!''}</#if>" type="text" maxlength="60" />
					</dd>
				</dl>
				<dl>
					<dt><@label key="default.C,distributionUser.C,colon">默认配送人员:</@label></dt>
					<dd>
						<input name="distributionUser" value="${pfep.distributionUser!''}" 
                              size="22" type="text" maxlength="40" class="required  alphanumeric toUp" 
                               id="userWarehouseLookup.userCode"
                              postField="userCode" suggestFields="userCode,userText" 
                              suggestUrl="${rc.getContextPath()}/manage/user/userSuggest" lookupGroup="userWarehouseLookup"
                              remote="${rc.getContextPath()}/manage/user/checkedUserCodeNotExits"
                              warn="<@label key='userCode.C,doesNotExist.C'>用户编号不存在</@label>"
                        />
					</dd>
				</dl>
				<dl>
					<dt>&nbsp;</dt>
					<dd>
						<input type="checkbox" name="lockFlag" value="1"<#if (pfep.lockFlag)?? && (pfep.lockFlag == 1)> checked="true"</#if>><@label key="lock.C">锁定</@label>
					</dd>
				</dl>
			</fieldset>
		</div>
		<#if (pfep.materialCode)??> <#assign createInfo=pfep/> <#include "/common/createInfo.html"> </#if>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive">
						<div class="buttonContent">
							<button type="submit"><@label key="save.B">保存</@label></button>
						</div>
					</div></li>
				<li>
					<div class="buttonActiveGrey">
						<div class="buttonContent">
							<button type="button" class="close"><@label key="cancel.B">取消</@label></button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</form>
</div>